package com.funtonow.jqdk.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.funtonow.jqdk.R;
import com.funtonow.jqdk.bean.RepaymentBean;
import com.funtonow.jqdk.utils.TimeUtils;

import java.util.List;
import java.util.Locale;

/**
 * @author Jiajien
 * @date 2019/8/23
 */
public class RepaymentAdapter extends BaseQuickAdapter<RepaymentBean, BaseViewHolder> {


    public RepaymentAdapter() {
        super(R.layout.item_fk_repayment);
    }

    @Override
    protected void convert(BaseViewHolder helper, RepaymentBean item) {
        if (helper.getAdapterPosition() == 0) {
            helper.setText(R.id.tv_hk_date, item.getTime())
                    .setText(R.id.tv_hk_num, item.getHuankuane())
                    .setText(R.id.tv_hk_money, item.getBenjin())
                    .setText(R.id.tv_hk_lx, item.getXifei());
        } else {
            helper.setText(R.id.tv_hk_date, TimeUtils.dateToString(Long.valueOf(item.getTime())))
                    .setText(R.id.tv_hk_num, String.format(Locale.getDefault(), "￥%s.00", item.getHuankuane()))
                    .setText(R.id.tv_hk_money, String.format(Locale.getDefault(), "￥%s.00", item.getBenjin()))
                    .setText(R.id.tv_hk_lx, String.format(Locale.getDefault(), "￥%s.00", item.getXifei()));
        }
    }

}
